package com.twu.numbers;

import java.util.ArrayList;
import java.util.List;

public class NumberGenerator {

    public static void fizzBuzz() {
        for (int i = 1; i <= 100; i++) {
			if(i % 15 == 0)
				System.out.println("FizzBuzz");
			else if(i % 3 == 0)
				System.out.println("Fizz");
			else if(i % 5 == 0)
				System.out.println("Buzz");
			else
				System.out.println(i);
		}
    }

    public static List<Integer> generate(int n) {
        List<Integer> listOfFactors = new ArrayList<Integer>();

        for(int num = 2; num <= n; num++) {
            boolean hasFactor = false;
            if(n % num == 0) {
                for(int factor : listOfFactors) {
                    if(num % factor == 0) {
                        hasFactor = true;
                        break;
                    }
                }

                if(!hasFactor)
                    listOfFactors.add(num);
            }
        }

        return listOfFactors;
    }
}
